import {
  Body,
  Controller,
  Delete,
  Get,
  Post,
  Query,
  UseGuards,
} from '@nestjs/common';
import { CategoryService } from './category.service';
import { AuthGuard } from '@nestjs/passport';

@Controller('category')
export class CategoryController {
  constructor(private readonly categoryService: CategoryService) {}

  // 获取书签分类列表
  @Get()
  categoryList(@Query() params) {
    return this.categoryService.categoryList(params);
  }

  // 创建书签分类
  @Post()
  @UseGuards(AuthGuard('jwt'))
  createCategory(@Body() bodyData) {
    return this.categoryService.createCategory(bodyData);
  }

  // 更新书签分类
  @Post('update')
  @UseGuards(AuthGuard('jwt'))
  updatedCategory(@Body() bodyData) {
    return this.categoryService.updatedCategory(bodyData);
  }

  // 删除书签分类
  @Delete()
  @UseGuards(AuthGuard('jwt'))
  delCategory(@Query() params) {
    return this.categoryService.delCategory(params);
  }

  // 获取书签分类下拉
  @Get('select')
  categorySelect() {
    return this.categoryService.categorySelect();
  }
}
